<template>
    <div>
           <!-- 头部 -->
        <div class="header">
            <div class="logo">
                <span class="spanimg" @click="Jump_path"></span><span class="longspan">目录</span>
            </div>
        </div>
        <!-- 目录内容区 -->
        <div id="scroller" class="comic-list-content">
            <span class="sort-btn" v-show="!falg" @click="isfalg">倒序</span>
            <span class="sort-btn inverted" v-show="falg" @click="isfalg">正序</span>
            <ul class="comic-list asc">
               <li v-for="item in catalist" :key="item.chapter_newid" @click="getcatanewid(item.chapter_newid)"><a href="javascript:;">{{item.chapter_name}}</a></li>
            </ul>
        </div>
    </div>
</template>
<script>
export default {
    props:['id'],
    data() {
        return {
            catalist:'',//存放数据
            falg:true,
            catanewid:'',
            catanewlist:null
        }
    },
    methods: {
        //返回上一级
         Jump_path() {
      this.$router.go(-1)
    },
    //获取数据
    getread(){
            this.$axios({
                url:'https://www.kanman.com/api/getchapterlist',
               method:'get',
            params:{
                comic_id:this.id,
            }
            }).then(data=>{
                console.log(data.data.data);
                this.catalist=data.data.data
            })
        },
        isfalg(){
            this.falg=!this.falg
            this.catalist=this.catalist.reverse()
        },
        //跳转阅读
        getcatanewid(id){
     this.$emit('getcatanewid',id)
     this.$router.push({name:'reading'})
        },
   
         
    },
      
    created() {

        this.getread()
    },
}
</script>
<style scoped>
/* 头部 */
.header{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 53px;
    background-color: #fff;
    padding: 13px 13px 0 13px;
    box-sizing: border-box;
    display: flex;
    border-bottom: 1px solid #b3b3b3;
    z-index: 999;
}
.logo{
    width: 130px;
    height: 26.5px;
    margin-right: 80px;
    line-height: 26.5px;
}
.spanimg{
    display: inline-block;
    width: 18px;
    height: 30px;
    background: url(../../public/assets/images-index/zjt.png) no-repeat;
  background-size: 70% 70%;
}
.longspan{
    font-size: 18px;
    display: inline-block;
    color: #333;
    margin-left: 12px;
    font-weight: 800;
position: relative;
top: -13px;
}

/* 目录区 */
.comic-list-content {
    box-sizing: border-box;
    text-align: right;
    padding: 15px 10px 10px 10px;
    margin-top: 50px;
}
#scroller{
        text-size-adjust: none;
    background: #fff;
    margin-top: 50px;
}
.sort-btn {
    display: inline-block;
    width: 50px;
    height: 16px;
    margin-right: 1.875px;
    line-height: 16px;
    font-size: 12px;
    color: #999;
}
.comic-list {
    text-align: center;
    margin: 12.5px 0px 0px 0px;
    overflow: auto;
    padding-top: 2px;
}

ul {
    list-style: none;
}
.comic-list li {
    position: relative;
}
.comic-list li {
    box-sizing: border-box;
    float: left;
    text-align: left;
    margin: 0 4.5px 15px 5.6px;
    width: 164px;
    height: 41px;
    border: 1px solid #c5c5c5;
    border-radius: 5px;
    line-height: 41px;
}
.comic-list li a {
    box-sizing: border-box;
    display: block;
    color: #444;
    font-size: 16px;
    width: 100%;
    height: 100%;
    padding: 0 15px 0 32px ;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

a {
    color: #333;
    text-decoration: none;
}
.sort-btn::after {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    background-image: url(../../public/assets/images-index/comic_sprite.png);
    background-repeat: no-repeat;
    background-size: 325px auto;
    background-position: -221px -28px;
    vertical-align: middle;
}
.sort-btn.inverted::after {
    background-position: -273px -28px;
}
</style>